package com.amit.jdbc.mysql;

import java.sql.Connection;

import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Lab3 {
	
	public static void main(String[] args) {
		
		try
		{
		//1.load the driver class
         
		Class.forName("com.mysql.jdbc.Driver");	
		//Class.forName("oracle.jdbc.driver.OracleDriver");
		
		//2.create the connection
		
		Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/amit007","root","root");
		//Connection con1=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","root");
		
		//3.create the statement
		
		Statement st=con.createStatement();
		
		System.out.println("amityadav");
		//4.prepare the sql query
		String sql="select * from jlcstudents";
		
		//5.submit the jdbc statement
		
		ResultSet rs=st.executeQuery(sql);
		
		//6.process the result
		
		
		
	while(rs.next())
	{
		int id=rs.getInt("id");
		String name=rs.getString(2);
		String email=rs.getString("email");
		long phone=rs.getLong(4);
		float fee=rs.getFloat("fee");
		Date dt=rs.getDate(6);
		
		int d=dt.getDate();
		int m=dt.getMonth();
		int y=dt.getYear();
		
		String dob=d+"-"+m+"-"+y;
		
		System.out.println(id+" "+name+" "+email+" "+phone+" "+fee+" "+dob);
		
	}
		
	
		
		con.close();
		}
		
		catch (Exception e) {
		
			System.out.println(e);
			
		}
		
		
	}

}
